<td valign="top">​​​​​<h1>Suggestions for making your OS</h1>
<p><b>1. Use a linker script.</b></p>
<p>I had lots of trouble with my kernel until I used a linker script. Basically, the linker script assures that your kernel gets linked into the right order(text,data,bss). Here is an example linker script for a kernel loaded at 0xFF80000(John Fine's bootf2.zip bootsector does this). Note that this linkere script is for LD:</p>
<p><i>kernel.lnk</i></p>
<pre class="code">OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
  .text  0xFF800000 : {
    *(.text)
  }
  .data  : {
    *(.data)
  }
  .bss  :
  { 					
    *(.bss)
  }
}
</pre>
<p>Then link like this:</p>
<pre>ld -T kernel.lnk  kernel.o</pre>

<p><b>2. Create a "boiler plate" file in ASM that runs the kernel.</b></p>
<p>I suggest that if your kernel is written in C, that you run your "kernel main" function from a ASM file like this(assuming PMode):</p>
<p><i>kernel_asm.asm</i></p>
<pre class="code">[bits 32] ; <i>hey, we're in PMode</i>

[global start]
[extern _kernel_main] ; <i>always add a "_" in front of a C function to call it</i>

start:
  call _kernel_main
  jmp $ ; halt
</pre>

<p><i>kernel_c.c</i></p>
<pre class="code">kernel_main()
{
     k_init();
     k_sayhello();
     ...
};
</pre>
<p>Then link the two files together.</p>

<p><b>3. Use and emulator so you don't have to reboot a computer constantly.</b></p>
<p>Rebooting a computer over and over again is slow, decreases the computer's lifespan, and a computer can't tell you easily what happened wrong in your code that caused a 3rd exception or general protection fault or something. An emulator such as <a href="http://bochs.sourceforge.net">Bochs</a> solves these problems.</p>

<p><b>4. Back up your code.</b></p>
<p>Back up your code whenever you make a major(or slightly major) change to it. This serves several purposes. First, it's easy to 'roll back' your source code if you've messed it up a lot. Second, you can use your backups to prove that you coded your OS if for some reason someone claims you just stole their code and modified it. And of course, you should also keep a backup of your code on a different computer or on a ZIP disk or CD somewhere in case your harddrive crashes and ruines your code.</p>

<p><b>5. When frustrated with a nasty bug or if you don't understand something, ask for help.</b></p>
<p>This is why OS development forums exist. The <a href="http://mega-tokyo.com/forum/">Mega-tokyo.com OS dev forum</a> is a terrific place to ask OS dev questions are ask for help fixing a bug in some code. You can also email me a question, though due to the huge amount of email I get per day and my busy schedual, I might not be able to answer it quickly. And remember, no question is too stupid.</p>

<p><b>6. Focus on your kernel, not on fancy graphics.</b></p>
<p>So many people want to have fancy graphics. Wait to work on graphics after your kernel is mature or completed. Why? Because graphics programming(especially SVGA) is as hard or harder than coding a kernel.</p>

<p><b>7. Understand what you are coding.</b></p>
<p>This seemingly obvious suggestion amazingly is not followed by many OS devers. It is a must that you understand what you are coding. And no borrowing code that you don't understand either. If you don't understand what the code does, you will eventually get some nasty bug(s) that you are going to have a hard time fixing. If you know how the code works, and understand it, fixing bugs is relativly easy.</p>

<p><b>8. Have fun.</b></p>
<p>Like any kinda of programming, you should only be a OS dever if you enjoy it. Simple as that. Don't do it just in the hopes that it will one day make you money. If you don't love doing it and have fun doing it, more likely that not, you will end up with a junk OS... if you don't give up first. The fact is, the good OS devers out there love OS development. And they have fun doing it as they love it.</p>

<br>
<p><i>Written by K.J. 2002. Updated 2002.11.20 and 2003.7.22 by K.J.</i>​​​​​</p>

     <div id="credit">© All Rights Reserved Bona Fide OS development 2001-2006. We Disclaim responsibility for all bad things, good things okay.
     			<!-- BEGIN pStats! Tracking Code -->
<script language="javascript"><!--
document.write('<a target="_new" href="http://www.pstats.com/scripts/reports.asp?id=613"><img alt="" border="0" src="');
document.write('http://www.pstats.com/scripts/stats.asp?id=613&loc=');
document.write(escape(document.location));
document.write('&ref=' + escape(document.referrer));
document.write('&res=' + screen.width + 'x' + screen.height);
document.write('&type=graphic">');
document.write('</'+'a>');
// --></script><a target="_new" href="http://www.pstats.com/scripts/reports.asp?id=613"><img alt="" src="http://www.pstats.com/scripts/stats.asp?id=613&amp;loc=http%3A//www.osdever.net/tutorials/mysuggestions.php&amp;ref=http%3A//www.osdever.net/tutorials.php%3Fcat%3D0%26sort%3D1&amp;res=1280x800&amp;type=graphic" border="0"></a>
<noscript><a href="http://www.pstats.com"><img src="http://www.pstats.com/scripts/stats.asp?id=613" alt="" border="0"></a></noscript>
<!-- END pStats! Tracking Code -->
</div></td>